package hasthi.tools.systemstat;

import hasthi.metamodel.resource.ManagedResource;
import hasthi.metamodel.resource.ManagedResource.ResourceType;

public class GroupStat {
    private int hostCount;
    private int serviceCount;
    private int computeNodeCount;
    private int transientServiceCount;
    public int getHostCount() {
        return hostCount;
    }
    public void setHostCount(int hostCount) {
        this.hostCount = hostCount;
    }
    public int getServiceCount() {
        return serviceCount;
    }
    public void setServiceCount(int serviceCount) {
        this.serviceCount = serviceCount;
    }
   
    public int getTransientServiceCount() {
        return transientServiceCount;
    }
    public void setTransientServiceCount(int transientServiceCount) {
        this.transientServiceCount = transientServiceCount;
    }
    
    public int getComputeNodeCount() {
        return computeNodeCount;
    }
    public void setComputeNodeCount(int computeCount) {
        this.computeNodeCount = computeCount;
    }
    public void reset(){
        hostCount = 0;
        serviceCount = 0;
        computeNodeCount = 0;
        transientServiceCount = 0;
    }
    
    public void update(ManagedResource resource, int val){
        ResourceType type = ResourceType.valueOf(resource.getCategory());
        switch(type){
            case Service:
                serviceCount = serviceCount + val;
                break;
            case ComputeNode:
                computeNodeCount = computeNodeCount + val;
                break;
            case Host:
                hostCount = hostCount + val;
                break;
            case TransientService:
                transientServiceCount = transientServiceCount + val;
        }
    }
}
